# -*- coding: utf-8 -*-
import numpy as np
from utils import gen_data
from numpy.linalg import pinv
from TriTraining.DisturbedTriTrainingClassifier2 import DisturbedTriTrainingClassifier as Dtri
from TriTraining.TriTrainingClassifier2 import TriTrainingClassifier as Tri
from TriTraining.TriTrainingClassifier5 import TriTrainingClassifier as MCTri
from sklearn.svm import SVC


if __name__ == '__main__':
    path = r'../data/csv/'
    name = 'diabetes.csv'
    train_data, train_label, test_data, test_label, labeled_data, labeled_label, unlabeled_data, unlabeled_label \
        = gen_data(path+name, unlabeled_rate=0.8, random_state=919)

    estimator = SVC()
    scores = []
    for i in range(3):
        scores.append([])

    for cycle in range(50):
        dtri = Dtri(estimator, unlabeled_data, unlabeled_label, noise_rate=0.1)
        tri = Tri(estimator, unlabeled_data, unlabeled_label)
        mctri = MCTri(estimator, unlabeled_data, unlabeled_label)

        dtri.fit(labeled_data, labeled_label)
        tri.fit(labeled_data, labeled_label)
        mctri.fit(labeled_data, labeled_label)

        scores[0].append(dtri.score(test_data, test_label))
        scores[1].append(tri.score(test_data, test_label))
        scores[2].append(mctri.score(test_data, test_label))

    print(np.average(scores, axis=1))




